package com.vavr.checkincms.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vavr.checkincms.common.domain.BaseResult;
import com.vavr.checkincms.common.domain.ResultEnum;
import com.vavr.checkincms.domain.bo.SystemUserInfoBO;
import com.vavr.checkincms.service.SystemLoginService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 登录Controller
 *
 * @since 2024.12
 */
public class SystemLoginController {
    /**
     * systemLoginService
     */
    private final SystemLoginService systemLoginService;

    public SystemLoginController(SystemLoginService systemLoginService) {
        this.systemLoginService = systemLoginService;
    }

    /**
     * 本地用户登录
     *
     * @return 登录结果
     */
    @PostMapping("/sso/login")
    public BaseResult<String> loginByCode(@RequestBody SystemUserInfoBO bo,
            HttpServletRequest request, HttpServletResponse response) {
        return BaseResult.of(ResultEnum.OK, systemLoginService.login(request, response, bo));
    }
}
